package com.doupi.partner.constant;

/**
 * 用户来源
 *
 * @author Alvin Wang
 * @version 1.0.0 @ 2017-04-16
 */
public enum UserTypeEnum {
	ME("自有粉丝", Byte.valueOf("1")), SECOND("裂变粉丝", Byte.valueOf("2")), PLATFORM("平台用户", Byte.valueOf("4"));

	private String name;
	private byte code;

	UserTypeEnum(String name, byte code) {
		this.name = name;
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public byte getCode() {
		return code;
	}

	/**
	 * 根据 code获取{@link UserTypeEnum}
	 *
	 * @param code
	 *            code
	 * @return {@link UserTypeEnum}
	 */
	public static UserTypeEnum getUserTypeByCode(byte code) {
		for (UserTypeEnum profitSource : values()) {
			if (code == profitSource.code) {
				return profitSource;
			}
		}
		return null;
	}
}
